/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package javaapplication6.UI;

import javaapplication6.ControlLayer.StatisticsControl;
import javaapplication6.DomainLayer.StatisticsLogOrders;
import javaapplication6.DomainLayer.StatisticsOfCompany;

/**
 *
 * @author meydlo
 */
public class StatisticsUI {

    private StatisticsControl statisticsControl;
    private Listener listener=new Listener();

    //testing purpose
    private StatisticsLogOrders statisticsLogOrders=StatisticsLogOrders.getLogOrders();

    public StatisticsUI()
    {
        statisticsControl=new StatisticsControl();
    }

    public void printChoices()
    {
        System.out.println("(1) view LogList"+
                "\n(2) view statistics"+
                "\n(3) exit"
                );
    }

    public void statisticsManager()
    {
        boolean exit=false;
        do{
            printChoices();
            int choice=listener.getLineInt();
            switch(choice){
                case 1:{
                    printStatistic();
                    break;
                }
                case 2:{
                    pritnStatisticsOfCompany();
                    break;
                }
                case 3:{
                    exit=true;
                    break;
                }
            }
        }while(exit==false);
    }

    public int getSellOrRent()
    {
        System.out.println("Statistics for:" +
                "\n(1)sell orders" +
                "\n(2)rent orders");

        int choice=0;
        do{
            choice=listener.getLineInt();
        }while(choice>2);

        return choice;
    }

    public boolean isDetail()
    {
        System.out.println("Write in detail?(y/n)");
        boolean detail=listener.getLineBoolean();
        return detail;
    }



    public void printStatistic(){
        int sellOrRent=getSellOrRent();
        boolean detail=isDetail();

        if(sellOrRent==1){
            statisticsControl.printSellOrdered(detail);
        }
        if(sellOrRent==2){
            statisticsControl.printRentOrdered(detail);
        }
    }

    public void pritnStatisticsOfCompany()
    {
        StatisticsOfCompany statisticsOfCompany=StatisticsOfCompany.getStatisticsOfCompany();
        System.out.println("number of customers: "+statisticsOfCompany.getCustomers()+
                "\nnumber of workers: "+statisticsOfCompany.getWorkers()+
                "\n\nmoney from Selling: "+statisticsOfCompany.getMoneyFromSell()+
                "\nmoney from renting: "+statisticsOfCompany.getMoneyFromRent()+
                "\nextra money from delay: "+statisticsOfCompany.getExtraMoney()+
                "\n-------------------------------------------------"+
                "\ntotal: "+statisticsOfCompany.getTotal());
    }

}
